package com.yeyks.controller.other;


import com.yeyks.other.model.AddressDivisionDTO;
import com.yeyks.other.service.AddressDivisionService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 地址信息表 前端控制器
 * </p>
 *
 * @author dagny
 * @since 2019-06-06
 */
@RestController
@RequestMapping("/address/division")
public class AddressDivisionController {


    private final AddressDivisionService addressDivisionService;

    @Autowired
    public AddressDivisionController(AddressDivisionService addressDivisionService) {
        this.addressDivisionService = addressDivisionService;
    }


    @ApiOperation("根据父类code获取子类的地址信息【为空时， 默认查询所有省】")
    @PostMapping("/get")
    public List<AddressDivisionDTO> getAddressByParentCode(@RequestParam(value = "divCode", defaultValue = "", required = false) String divCode,
                                                           @ApiParam(name = "sourceType", value = "资源类型", allowableValues = "yyks,cn")
                                                           @RequestParam(value = "sourceType", defaultValue = "yyks")String sourceType) {

        return addressDivisionService.getAddressByParentCode(divCode, sourceType);
    }

}

